<%@page import="modulo1.cdp.Disciplina"%>
<%@page import="java.util.List"%>
<div class="table" style="border-top:2px solid #f70;">
    <br />
    <form method="post" id="evento">
    <input type="hidden" name="evento" value="inserir" />
    <a id="salvar" class="button" style="cursor: pointer;">Salvar</a>
    <a class="button" style="cursor: pointer;" onclick="history.back(-1)">Voltar</a><br />
    <table class="listing form" cellpadding="0" cellspacing="0">
        <tr>
            <th class="full" colspan="2">Turma</th>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Curso</strong></td>
            <td class="last"><input type="text" id="curso" name="curso" class="text" value="<%=request.getAttribute("curso")%>" disabled="disabled" /></td>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Disciplina</strong></td>
            <td class="last">
              <select name="disciplina">
                <%
                  List<Disciplina> listaDisciplinas = (List<Disciplina>) request.getAttribute("listaDisciplinas");
                  if(listaDisciplinas != null) { for (int i = 0; i < listaDisciplinas.size(); i++) {
                    out.print("<option value=\"" + listaDisciplinas.get(i).getId() + "\">" + listaDisciplinas.get(i).getNome() + "</option>");
                  } }
                %>
              </select>
            </td>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Ano</strong></td>
            <td class="last"><input type="text" id="ano" name="ano" class="text" /></td>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Semestre</strong></td>
            <td class="last"><input type="text" id="periodo" name="periodo" class="text" /></td>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Qntd. min. de alunos</strong></td>
            <td class="last"><input type="text" id="qntdminalunos" name="qntdminalunos" class="text" /></td>
        </tr>
        <tr>
            <td class="first" width="172"><strong>Qntd. max. de alunos</strong></td>
            <td class="last"><input type="text" id="qntdmaxalunos" name="qntdmaxalunos" class="text" /></td>
        </tr>
    </table>
    <p>&nbsp;</p>
    </form>
</div>
<script>
$("#salvar").click(function(){
    if(!$.isNumeric($("#ano").val())) {
        alert("Informar valor inteiro ano");
        $("#ano").focus();
        return false;
    } else {
        $("#ano").val(Math.floor($("#ano").val()));
    }
    if(!$.isNumeric($("#periodo").val())) {
        alert("Informar valor inteiro periodo");
        $("#periodo").focus();
        return false;
    } else {
        $("#periodo").val(Math.floor($("#periodo").val()));
    }
    if(!$.isNumeric($("#qntdminalunos").val())) {
        alert("Informar valor inteiro qntdminalunos");
        $("#qntdminalunos").focus();
        return false;
    } else {
        $("#qntdminalunos").val(Math.floor($("#qntdminalunos").val()));
    }
    if(!$.isNumeric($("#qntdmaxalunos").val())) {
        alert("Informar valor inteiro qntdmaxalunos");
        $("#qntdmaxalunos").focus();
        return false;
    } else {
        $("#qntdmaxalunos").val(Math.floor($("#qntdmaxalunos").val()));
    }
    $("#evento").submit();
});
</script>